<template><app-layout>
		<view class="template-order">
			<!-- 顶部自定义导航 -->
			<tn-nav-bar> </tn-nav-bar>
			<view class="tabs-fixed tn-bg-white">
				<view class="tn-flex tn-flex-col-between tn-flex-col-center tn-padding-top-sm"
					:style="{marginTop: vuex_custom_bar_height + 'px'}">
					<view class="justify-content-item" style="width: 87vw;overflow: hidden;">
						<tn-tabs ref="tabs" class="tabs" :list="tablist" :countshow="!!1" :isScroll="false"
							:current="cur" name="name" style="width: 87vw;" @change="tabsChange"></tn-tabs>
					</view>

					<view class="justify-content-item" style="width: 13vw;overflow: hidden;" @click="findshow">
						<view class="tn-color-black tn-round"
							style="font-size: 45rpx;margin-top: -5rpx;margin-left: 15rpx;">
							<text class="tn-icon-search tn-padding-xs"></text>
						</view>

					</view>
				</view>
			</view>

			<userlist @userclick="checkface" :list="userlist" :fjfl="false"  :issearch="search"></userlist>
			<view class="">
				<userselect ref="userselect" @select="findsome" @close="userclose" ></userselect>
			</view>
		</view>
	</app-layout>
</template>

<script>
	import templatePageMixin from '@/libs/mixin/template_page_mixin.js'
	import userselect from '@/components/user-select.vue';
	
	export default {
		name: 'physicallist',
		mixins: [templatePageMixin],
		components: {
			userselect
		},
		data() {
			return {
				tablist: [{
					name: '全部'
				}],
				type: 0,
				cur:0,
				userlist: [],
				search: '',
				page: 1,
			}
		},
		onLoad(options) {
			this.type = options.type ? options.type : this.type;
			uni.setNavigationBarTitle({
				title: this.type == 2 ? '待上传结果' : '待体检提交'
			})
			this.getList();
		},
		onReady() {

		},
		onReachBottom() {
			this.getList();
		},

		methods: {
			// 标签栏值发生改变
			tabsChange(index) {
				this.cur = index
				this.page = 1;
				this.getList();
			},
			// 跳转
			checkface(user) {
				if (this.userinfo.usergroup == 'pcs' || this.userinfo.usergroup == 'zr') {
					return false;
				}
				//任务模式 1待上传任务
				let return_url = `/discoveryPages/physical/add?mfid=${user.mfid}&tid=${user.id}`
				//任务模式 2待上传结果
				if (this.type == 2) {
					return_url = `/discoveryPages/upresult/add?mfid=${user.mfid}&tid=${user.id}`
				}
				uni.navigateTo({
					url: return_url
				});
			},
			getList() {
				let t = this;
				this.$t.message.loading('加载中');
				this.$request({
					url: this.$api.physical.list,
					data: {
						limit_page: t.page,limit_count:20,
						type: t.type,
						fcfl: t.tablist.length > 0 ? t.tablist[t.cur].name : '全部',
						...t.search
					}
				}).then(response => {
					this.$t.message.closeLoading();
					if (response.code === 0) {
						if (response.fcfl && response.fcfl.length > 0) {
							t.tablist = response.fcfl
							
						}
						if (this.page !== 1) {
							this.userlist = this.userlist.concat(response.list);
						} else {
							this.userlist = response.list;
						}
						this.page = response.list.length ? this.page + 1 : this.page;
					}
				}).catch((msg) => {
					this.$t.message.toast(msg);
					this.$t.message.closeLoading();
				});
			},


			findsome(e) {
				this.page = 1;
				this.search = e;
				this.getList()
			},

			findshow() {
				//关闭搜索框
				this.$refs['userselect'].show = !!1;
			},

			userclose(e) {
			},
		}
	}
</script>

<style lang="scss" scoped>
	.nobody {
		height: 500rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}


	.face {
		width: 100rpx;
		height: 100rpx;
		border-radius: 10rpx;
		box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
	}

	.userlist {
		padding-top: 10rpx;
		position: relative;

		.user {
			position: relative;
			margin: 20rpx;
			padding: 36rpx 26rpx;
			border-radius: 15rpx;
			background-color: #fff;
			box-shadow: 0px 0px 26px 0px rgba(0, 0, 0, 0.07);
		}

		.usertag {
			position: absolute;
			top: 10rpx;
			right: 10rpx;
		}
	}
</style>